package utils

import (
	"MoSkeleton/config/consts"
	"fmt"
	"golang.org/x/exp/rand"
	"path/filepath"
	"time"
)

func DatePath() string {
	return time.Now().Format(fmt.Sprintf("2006%c01%c02", filepath.Separator, filepath.Separator))
}

/*
*
redis 缓存过期时间，+ 随机2分钟 防止缓存雪崩
@param duration : 秒
*/
func RedisExpireDuration(duration time.Duration) time.Duration {
	return (duration + time.Duration(rand.Intn(consts.Redis_Expire_Time_Rand))) * time.Second
}

func init() {
	rand.Seed(uint64(time.Now().UnixNano()))
}
